<?php
require_once 'BaseMySQLDAO.php';

class GameDAO extends BaseMySQLDAO {

    public function __construct($context) {
        parent::__construct($context, 'game');
    }

	public function getGameTempTPG() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "	SELECT * FROM game_temp ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	/*public function getGameTempTPGtoMMBG() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "	SELECT * FROM game_temp WHERE id = 2 ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }*/
    
    public function getGameByParentTPG($parent, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "	SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game.parent = :parent
                        ORDER BY game.created_date DESC
            			LIMIT :start, :limit ";
            $param = array(":parent" => $parent, ":start" => $start, ":limit" => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByParentMobile($parent, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "	SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game.parent = :parent
                        ORDER BY game.created_date DESC
            			LIMIT :start, :limit ";
            $param = array(":parent" => $parent, ":start" => $start, ":limit" => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByParentAndTypeMobile($parent, $type) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "	SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game.parent = :parent
                        AND game.type = :type
                        ORDER BY game.created_date DESC
            		 ";
            $param = array(":parent" => $parent, ":type" => $type);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByParentAndTypeTPG($parent, $type) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "	SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game.parent = :parent
                        AND game.type = :type
                        ORDER BY game.created_date DESC
            		 ";
            $param = array(":parent" => $parent, ":type" => $type);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByParentAndTypeCGMB($parent, $type) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "	SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game.parent = :parent
                        AND game.type = :type
                        ORDER BY game.created_date DESC
            		 ";
            $param = array(":parent" => $parent, ":type" => $type);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByParentAndTypeMMBG($parent, $type) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "	SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game.parent = :parent
                        AND game.type = :type
                        ORDER BY game.created_date DESC
            		 ";
            $param = array(":parent" => $parent, ":type" => $type);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByParentAndTypeNSGT($parent, $type) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "	SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game.parent = :parent
                        AND game.type = :type
                        ORDER BY game.created_date DESC
            		 ";
            $param = array(":parent" => $parent, ":type" => $type);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByParentCGMB($parent, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "	SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game.parent = :parent
                        ORDER BY game.created_date DESC
            			LIMIT :start, :limit ";
            $param = array(":parent" => $parent, ":start" => $start, ":limit" => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByParentMMBG($parent, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "	SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game.parent = :parent
                        ORDER BY game.created_date DESC
            			LIMIT :start, :limit ";
            $param = array(":parent" => $parent, ":start" => $start, ":limit" => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByParentNSGT($parent, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "	SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game.parent = :parent
                        ORDER BY game.created_date DESC
            			LIMIT :start, :limit ";
            $param = array(":parent" => $parent, ":start" => $start, ":limit" => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
    public function countFullGame() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction();

            $inSQL = "  SELECT count(game.id) as total FROM game, game_category
                        WHERE game.parent = game_category.id
                        ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countFullGameTPG() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "  SELECT count(game.id) as total FROM game, game_category
                        WHERE game.parent = game_category.id
                        ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countFullGameMobile() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "  SELECT count(game.id) as total FROM game, game_category
                        WHERE game.parent = game_category.id
                        ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countFullGameCGMB() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "  SELECT count(game.id) as total FROM game, game_category
                        WHERE game.parent = game_category.id
                        ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countFullGameMMBG() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "  SELECT count(game.id) as total FROM game, game_category
                        WHERE game.parent = game_category.id
                        ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countFullGameNSGT() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "  SELECT count(game.id) as total FROM game, game_category
                        WHERE game.parent = game_category.id
                        ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }

	public function getFullGameByLimitTPG($start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "  SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        ORDER BY game.created_date DESC
                        LIMIT :start, :limit";
            $param = array(':start' => $start, ':limit' => $limit);
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getFullGameByLimitMobile($start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "  SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        ORDER BY game.created_date DESC
                        LIMIT :start, :limit";
            $param = array(':start' => $start, ':limit' => $limit);
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getFullGameByLimitCGMB($start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "  SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        ORDER BY game.created_date DESC
                        LIMIT :start, :limit";
            $param = array(':start' => $start, ':limit' => $limit);
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getFullGameByLimitMMBG($start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "  SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        ORDER BY game.created_date DESC
                        LIMIT :start, :limit";
            $param = array(':start' => $start, ':limit' => $limit);
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getFullGameByLimitNSGT($start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "  SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        ORDER BY game.created_date DESC
                        LIMIT :start, :limit";
            
            $param = array(':start' => $start, ':limit' => $limit);
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
    public function getFullGame($start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction();

            $inSQL = "  SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        ORDER BY game.created_date DESC
                        LIMIT :start, :limit";
            $param = array(':start' => $start, ':limit' => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }

    public function getFullGame1() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction();

            $inSQL = "  SELECT game.*,game_category.name as parent FROM game, game_category
                        WHERE game.parent = game_category.id
                        ORDER BY game.created_date DESC
                        ";

            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByIsGame() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "SELECT * FROM game WHERE isGame = 1";
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByIsGameCGMB() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "SELECT * FROM game WHERE isGame = 1";
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByIsGameMMBG() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "SELECT * FROM game WHERE isGame = 1";
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByIsGameNSGT() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "SELECT * FROM game WHERE isGame = 1";
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
    public function countGameByEventTPG($isEvent) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "SELECT count(id) as total FROM game WHERE isEvent = :isEvent ";
            $param = array(":isEvent" => $isEvent);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameByEventMobile($isEvent) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "SELECT count(id) as total FROM game WHERE isEvent = :isEvent ";
            $param = array(":isEvent" => $isEvent);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameByEventCGMB($isEvent) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "SELECT count(id) as total FROM game WHERE isEvent = :isEvent ";
            $param = array(":isEvent" => $isEvent);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameByEventMMBG($isEvent) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "SELECT count(id) as total FROM game WHERE isEvent = :isEvent ";
            $param = array(":isEvent" => $isEvent);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameByEventNSGT($isEvent) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "SELECT count(id) as total FROM game WHERE isEvent = :isEvent ";
            $param = array(":isEvent" => $isEvent);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
    public function getGameEventTPG($isEvent, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "	SELECT * 
            			FROM game 
            			WHERE isEvent = :isEvent 
            			ORDER BY `created_date` DESC, `order` ASC
            			LIMIT :start, :limit
            		";
            $param = array(':isEvent' => $isEvent, ':start' => $start, ':limit' => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameEventMobile($isEvent, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "	SELECT * 
            			FROM game 
            			WHERE isEvent = :isEvent 
            			ORDER BY `created_date` DESC, `order` ASC
            			LIMIT :start, :limit
            		";
            $param = array(':isEvent' => $isEvent, ':start' => $start, ':limit' => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
 	public function getGameEventCGMB($isEvent, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "	SELECT * 
            			FROM game 
            			WHERE isEvent = :isEvent 
            			ORDER BY `created_date` DESC, `order` ASC
            			LIMIT :start, :limit
            		";
            $param = array(':isEvent' => $isEvent, ':start' => $start, ':limit' => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameEventMMBG($isEvent, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "	SELECT * 
            			FROM game 
            			WHERE isEvent = :isEvent 
            			ORDER BY `created_date` DESC, `order` ASC
            			LIMIT :start, :limit
            		";
            $param = array(':isEvent' => $isEvent, ':start' => $start, ':limit' => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameEventNSGT($isEvent, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "	SELECT * 
            			FROM game 
            			WHERE isEvent = :isEvent 
            			ORDER BY `created_date` DESC, `order` ASC
            			LIMIT :start, :limit
            		";
            $param = array(':isEvent' => $isEvent, ':start' => $start, ':limit' => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }

    public function getAllGame($limit = null) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction();

            $inSQL = "  SELECT game.* FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game_category.parent != 78
                        ORDER BY isEvent DESC, game.created_date DESC ";
            if($limit != null)
                $inSQL .= 'LIMIT 0,' . $limit;
            $param = array();
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getAllGameMMBG($limit = null) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "  SELECT game.* FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game_category.parent != 78
                        ORDER BY isEvent DESC, game.created_date DESC ";
            if($limit != null)
                $inSQL .= 'LIMIT 0,' . $limit;
            $param = array();
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getAllGameMobile($limit = null) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "  SELECT game.* FROM game, game_category
                        WHERE game.parent = game_category.id
                        AND game_category.parent != 78
                        ORDER BY isEvent DESC, game.created_date DESC ";
            if($limit != null)
                $inSQL .= 'LIMIT 0,' . $limit;
            $param = array();
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }

    public function getFullGameOnline($limit = null) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction();

            $inSQL = "  SELECT g.*
                        FROM game g, game_category gc
                        WHERE g.parent = gc.id
                        AND gc.parent = 2
                        GROUP BY g.parent
                        ORDER BY gc.order ASC ";
            if($limit != null)
                $inSQL .= 'LIMIT 0,' . $limit;
            $param = array();
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }

    public function getFullGameByParentID($limit = null) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction();

            $inSQL = "  SELECT gc.*
                        FROM game g, game_category gc
                        WHERE g.parent = gc.id
                        GROUP BY g.parent
                        ORDER BY gc.order ASC ";
            if($limit != null)
                $inSQL .= 'LIMIT 0,' . $limit;
            $param = array();
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }

    public function countGameByParentTPG($parent) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "SELECT count(id) as total FROM game WHERE parent = :parent ";
            $param = array(":parent" => $parent);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameByParentMobile($parent) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "SELECT count(id) as total FROM game WHERE parent = :parent ";
            $param = array(":parent" => $parent);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameByParentCGMB($parent) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "SELECT count(id) as total FROM game WHERE parent = :parent ";
            $param = array(":parent" => $parent);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameByParentMMBG($parent) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "SELECT count(id) as total FROM game WHERE parent = :parent ";
            $param = array(":parent" => $parent);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameByParentNSGT($parent) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "SELECT count(id) as total FROM game WHERE parent = :parent ";
            $param = array(":parent" => $parent);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }

    public function getGameByIDTPG($id) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "SELECT * FROM game WHERE id = :id";
            $param = array(":id" => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
 	public function getGameByIDMobile($id) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "SELECT * FROM game WHERE id = :id";
            $param = array(":id" => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByIDCGMB($id) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "SELECT * FROM game WHERE id = :id";
            $param = array(":id" => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByIDMMBG($id) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "SELECT * FROM game WHERE id = :id";
            $param = array(":id" => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByIDNSGT($id) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "SELECT * FROM game WHERE id = :id";
            $param = array(":id" => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }

	public function countGameByHotStarTPG($hotStar) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "  SELECT count(id) as total
                        FROM game
                        WHERE hot_star = :hot_star
                    ";
            $param = array(":hot_star" => $hotStar);
           	
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameByHotStarMobile($hotStar) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "  SELECT count(id) as total
                        FROM game
                        WHERE hot_star = :hot_star
                    ";
            $param = array(":hot_star" => $hotStar);
           	
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameByHotStarCGMB($hotStar) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "  SELECT count(id) as total
                        FROM game
                        WHERE hot_star = :hot_star
                    ";
            $param = array(":hot_star" => $hotStar);
           	
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameByHotStarMMBG($hotStar) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "  SELECT count(id) as total
                        FROM game
                        WHERE hot_star = :hot_star
                    ";
            $param = array(":hot_star" => $hotStar);
           	
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameByHotStarNSGT($hotStar) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "  SELECT count(id) as total
                        FROM game
                        WHERE hot_star = :hot_star
                    ";
            $param = array(":hot_star" => $hotStar);
           	
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
    public function getGameByHotStarTPG($hotStar, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "  SELECT *
                        FROM game
                        WHERE hot_star = :hot_star
                        AND `status` > 0
                        ORDER BY `order` ASC
                        LIMIT :start, :limit
                    ";
            $param = array(':hot_star' => $hotStar, ':start' => $start, ':limit' => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByHotStarMobile($hotStar, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "  SELECT *
                        FROM game
                        WHERE hot_star = :hot_star
                        AND `status` > 0
                        ORDER BY `order` ASC
                        LIMIT :start, :limit
                    ";
            $param = array(':hot_star' => $hotStar, ':start' => $start, ':limit' => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByHotStarCGMB($hotStar, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "  SELECT *
                        FROM game
                        WHERE hot_star = :hot_star
                        AND `status` > 0
                        ORDER BY `order` ASC
                        LIMIT :start, :limit
                    ";
            $param = array(':hot_star' => $hotStar, ':start' => $start, ':limit' => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByHotStarMMBG($hotStar, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "  SELECT *
                        FROM game
                        WHERE hot_star = :hot_star
                        AND `status` > 0
                        ORDER BY `order` ASC
                        LIMIT :start, :limit
                    ";
            $param = array(':hot_star' => $hotStar, ':start' => $start, ':limit' => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameByHotStarNSGT($hotStar, $start, $limit) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "  SELECT *
                        FROM game
                        WHERE hot_star = :hot_star
                        AND `status` > 0
                        ORDER BY `order` ASC
                        LIMIT :start, :limit
                    ";
            $param = array(':hot_star' => $hotStar, ':start' => $start, ':limit' => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }

    public function getGameLink($id) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction();

            $inSQL = "  SELECT game_link.*, device_name
                        FROM game_link LEFT JOIN device ON game_link.device_id = device.id
                        WHERE game_category_id = :id";
            $param = array(":id" => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }

    public function getGameMessage($id) {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction();

            $inSQL = "  SELECT *
                        FROM game_message
                        WHERE game_category_id = :id";
            $param = array(":id" => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }

    public function increaseView ($id, $view) {
        try {
            $this -> getContext() -> getTransaction() -> startTransaction();

            $inSQL = "  UPDATE game SET view = view + :view WHERE id = :id ";
            $param = array(":view" => $view, ':id' => $id);
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }

    public function updateEvent ($id, $eventStatus) {
        try {
            $this -> getContext() -> getTransaction() -> startTransaction();

            $inSQL = "  UPDATE game SET isEvent = :eventStatus WHERE id = :id ";
            $param = array(":eventStatus" => $eventStatus, ':id' => $id);
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
	public function updateEventByExpireDate() {
        try {
           
            $inSQL = "  UPDATE game SET isEvent = 0 
            			WHERE isEvent = 1 AND `expire_date` > 0 AND expire_date < CURRENT_DATE() ";
            $queryParam = array();
            
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();    
            
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();

            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
            
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
public function insertGame($param) {
        $result = null;

        try {
            $inSQL = "INSERT INTO
                        game(id, name, mediumName, 	unique_name, SEO_Name, smallImage, mediumImage, largeImage, xlargeImage, shortDetail, mediumDetail, longDetail, parent, SEO_title, SEO_metaDescription, SEO_keyword, hot_star, isEvent, expire_date, type, link_canonical)
                        VALUES (
                            :id, :name, :mediumName, :unique_name, :SEO_Name, :smallImage, :mediumImage, :largeImage, :xlargeImage, :shortDetail, :mediumDetail, :longDetail, :parent, :SEO_title, :SEO_metaDescription, :SEO_keyword, :hot_star, :isEvent, :expire_date, :type, :link_canonical
                        )";
            $queryParam = array(
                                ':id' => NULL,
                                ':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':SEO_Name' => $param['SEO_Name'],
                                ':smallImage' => $param['smallImage'],
                                ':mediumImage' => $param['mediumImage'],
                                ':largeImage' => $param['largeImage'],
            					':xlargeImage' => $param['xlargeImage'],
                                ':shortDetail' => $param['shortDetail'],
                                ':mediumDetail' => $param['mediumDetail'],
                                ':longDetail' => $param['longDetail'],
                                ':parent' => $param['parent'],
                                ':SEO_title' => $param['SEO_title'],
                                ':SEO_metaDescription' => $param['SEO_metaDescription'],
                                ':SEO_keyword' => $param['SEO_keyword'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
                                ':expire_date' => $param['expire_date'],
            					':type' => $param['type'],
            					':link_canonical' => $param['link_canonical']
                            );
                            
			$oldLongDetail = $queryParam[':longDetail'];

            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
			$queryParam[':longDetail'] = str_replace("#WEB_URL#", "http://thanhphogame.com", $oldLongDetail);
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();

            /*$this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');
			$queryParam[':longDetail'] = str_replace("#WEB_URL#", "http://choigamemobi.com", $oldLongDetail);
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();*/

            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');
			$queryParam[':longDetail'] = str_replace("#WEB_URL#", "http://mymobigame.com", $oldLongDetail);
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
            
            /*$this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');
			$queryParam[':longDetail'] = str_replace("#WEB_URL#", "http://ngoisaogamethu.com", $oldLongDetail);
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();*/
            
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');
			$queryParam[':longDetail'] = str_replace("#WEB_URL#", "http://mobile.thanhphogame.com", $oldLongDetail);
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();


        } catch (Exception $exception) {
			$this -> getContext() -> getTransaction() -> closeTransaction();
        }
        return $result;
    }
    
	public function insertGameMMBG($param) {
        $result = null;

        try {
            $inSQL = "INSERT INTO
                        game(id, name, mediumName, 	unique_name, SEO_Name, smallImage, mediumImage, largeImage, xlargeImage, shortDetail, mediumDetail, longDetail, parent, SEO_metaDescription, SEO_keyword, hot_star, isEvent, expire_date, type, link_canonical)
                        VALUES (
                            :id, :name, :mediumName, :unique_name, :SEO_Name, :smallImage, :mediumImage, :largeImage, :xlargeImage, :shortDetail, :mediumDetail, :longDetail, :parent, :SEO_metaDescription, :SEO_keyword, :hot_star, :isEvent, :expire_date, :type, :link_canonical
                        )";
            $queryParam = array(
                                ':id' => NULL,
                                ':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':SEO_Name' => $param['SEO_Name'],
                                ':smallImage' => $param['smallImage'],
                                ':mediumImage' => $param['mediumImage'],
                                ':largeImage' => $param['largeImage'],
            					':xlargeImage' => $param['xlargeImage'],
                                ':shortDetail' => $param['shortDetail'],
                                ':mediumDetail' => $param['mediumDetail'],
                                ':longDetail' => $param['longDetail'],
                                ':parent' => $param['parent'],
                                ':SEO_metaDescription' => $param['SEO_metaDescription'],
                                ':SEO_keyword' => $param['SEO_keyword'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
                                ':expire_date' => $param['expire_date'],
            					':type' => $param['type'],
            					':link_canonical' => $param['link_canonical']
                            );
                            
			$oldLongDetail = $queryParam[':longDetail'];
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');
			$queryParam[':longDetail'] = str_replace("#WEB_URL#", "http://mymobigame.com", $oldLongDetail);
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
            
            /*$this -> getContext() -> getTransaction() -> startTransaction('mobile');
			$queryParam[':longDetail'] = str_replace("#WEB_URL#", "http://mobile.thanhphogame.com", $oldLongDetail);
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();*/

        } catch (Exception $exception) {
			$this -> getContext() -> getTransaction() -> closeTransaction();
        }
        return $result;
    }
    
	public function insertGameTemp($param) {
        $result = null;
        try {
            $inSQL = "INSERT INTO
                        game_temp(id, name, mediumName, unique_name, SEO_Name, smallImage, mediumImage, largeImage, xlargeImage, shortDetail, mediumDetail, parent, SEO_metaDescription, SEO_keyword, hot_star, isEvent, expire_date, type, link_canonical)
                        VALUES (
                            :id, :name, :mediumName, :unique_name, :SEO_Name, :smallImage, :mediumImage, :largeImage, :xlargeImage, :shortDetail, :mediumDetail, :parent, :SEO_metaDescription, :SEO_keyword, :hot_star, :isEvent, :expire_date, :type, :link_canonical
                        )";
            $queryParam = array(
                                ':id' => $param['id'],
                                ':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':SEO_Name' => $param['SEO_Name'],
                                ':smallImage' => $param['smallImage'],
                                ':mediumImage' => $param['mediumImage'],
                                ':largeImage' => $param['largeImage'],
            					':xlargeImage' => $param['xlargeImage'],
                                ':shortDetail' => $param['shortDetail'],
                                ':mediumDetail' => $param['mediumDetail'],
                                ':parent' => $param['parent'],
                                ':SEO_metaDescription' => $param['SEO_metaDescription'],
                                ':SEO_keyword' => $param['SEO_keyword'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
                                ':expire_date' => $param['expire_date'],
            					':type' => $param['type'],
            					':link_canonical' => $param['link_canonical']
                            );

            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();         

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function insertGameMobile($param) {
        $result = null;
        try {
            $inSQL = "INSERT INTO
                        game(id, name, mediumName, 	unique_name, SEO_Name, smallImage, mediumImage, largeImage, xlargeImage, shortDetail, mediumDetail, longDetail, parent, SEO_metaDescription, SEO_keyword, hot_star, isEvent, expire_date, type, link_canonical)
                        VALUES (
                            :id, :name, :mediumName, :unique_name, :SEO_Name, :smallImage, :mediumImage, :largeImage, :xlargeImage, :shortDetail, :mediumDetail, :longDetail, :parent, :SEO_metaDescription, :SEO_keyword, :hot_star, :isEvent, :expire_date, :type, :link_canonical
                        )";
            $queryParam = array(
                                ':id' => NULL,
                                ':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':SEO_Name' => $param['SEO_Name'],
                                ':smallImage' => $param['smallImage'],
                                ':mediumImage' => $param['mediumImage'],
                                ':largeImage' => $param['largeImage'],
            					':xlargeImage' => $param['xlargeImage'],
                                ':shortDetail' => $param['shortDetail'],
                                ':mediumDetail' => $param['mediumDetail'],
                                ':longDetail' => $param['longDetail'],
                                ':parent' => $param['parent'],
                                ':SEO_metaDescription' => $param['SEO_metaDescription'],
                                ':SEO_keyword' => $param['SEO_keyword'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
                                ':expire_date' => $param['expire_date'],
            					':type' => $param['type'],
            					':link_canonical' => $param['link_canonical']
                            );

            $this -> getContext() -> getTransaction() -> startTransaction('mobile');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();


        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }

	public function updateLongDetailGameTemp($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game_temp SET
                              longDetail = :longDetail
                        WHERE id = :id
                        ";
            $queryParam = array(
            					':id' => '1',
                                ':longDetail' => $param['longDetail'],
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateLongDetailMMBGGameTemp($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game_temp SET
                              longDetail = :longDetail
                        WHERE id = :id
                        ";
            $queryParam = array(
            					':id' => '2',
                                ':longDetail' => $param['longDetail'],
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateLongDetailGameTPG($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
                              longDetail = :longDetail
                        WHERE id = :id
                        ";
            $queryParam = array(
            					':id' => '1',
                                ':longDetail' => $param['longDetail'],
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateLongDetailGameCGMB($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
                              longDetail = :longDetail
                        WHERE id = :id
                        ";
            $queryParam = array(
            					':id' => '1',
                                ':longDetail' => $param['longDetail'],
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateLongDetailGameMMBG($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
                              longDetail = :longDetail
                        WHERE id = :id
                        ";
            $queryParam = array(
            					':id' => '1',
                                ':longDetail' => $param['longDetail'],
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateLongDetailGameMobile($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
                              longDetail = :longDetail
                        WHERE id = :id
                        ";
            $queryParam = array(
            					':id' => '1',
                                ':longDetail' => $param['longDetail'],
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateLongDetailGameNSGT($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
                              longDetail = :longDetail
                        WHERE id = :id
                        ";
            $queryParam = array(
            					':id' => '1',
                                ':longDetail' => $param['longDetail'],
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
    public function updateGameTPG($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
                                    name = :name,
                                    mediumName = :mediumName,
                                    unique_name = :unique_name,
                                    SEO_Name = :SEO_Name,
                                    smallImage = :smallImage,
                                    mediumImage = :mediumImage,
                                    largeImage = :largeImage,
                                    xlargeImage = :xlargeImage,
                                    shortDetail = :shortDetail,
                                    mediumDetail = :mediumDetail,
                                    longDetail = :longDetail,
                                    parent = :parent,
                                    SEO_metaDescription = :SEO_metaDescription,
                                    SEO_keyword = :SEO_keyword,
                                    status = :status,
                                    `order` = :order,
                                    hot_star = :hot_star,
                                    isEvent = :isEvent,
                                    isGame = :isGame,
                                    expire_date = :expire_date,
                                    type = :type,
                                    link_canonical = :link_canonical
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
                                ':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':SEO_Name' => $param['SEO_Name'],
                                ':smallImage' => $param['smallImage'],
                                ':mediumImage' => $param['mediumImage'],
                                ':largeImage' => $param['largeImage'],
            					':xlargeImage' => $param['xlargeImage'],
                                ':shortDetail' => $param['shortDetail'],
                                ':mediumDetail' => $param['mediumDetail'],
                                ':longDetail' => $param['longDetail'],
                                ':parent' => $param['parent'],
                                ':SEO_metaDescription' => $param['SEO_metaDescription'],
                                ':SEO_keyword' => $param['SEO_keyword'],
                                ':status' => $param['status'],
                                ':order' => $param['order'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
                                ':isGame' => $param['isGame'],
                                ':expire_date' => $param['expire_date'],
            					':type' => $param['type'],
            					':link_canonical' => $param['link_canonical']
                            );

            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateGameMobile($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
                                    name = :name,
                                    mediumName = :mediumName,
                                    unique_name = :unique_name,
                                    SEO_Name = :SEO_Name,
                                    smallImage = :smallImage,
                                    mediumImage = :mediumImage,
                                    largeImage = :largeImage,
                                    xlargeImage = :xlargeImage,
                                    shortDetail = :shortDetail,
                                    mediumDetail = :mediumDetail,
                                    longDetail = :longDetail,
                                    parent = :parent,
                                    SEO_metaDescription = :SEO_metaDescription,
                                    SEO_keyword = :SEO_keyword,
                                    status = :status,
                                    `order` = :order,
                                    hot_star = :hot_star,
                                    isEvent = :isEvent,
                                    isGame = :isGame,
                                    expire_date = :expire_date,
                                    type = :type,
                                    link_canonical = :link_canonical
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
                                ':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':SEO_Name' => $param['SEO_Name'],
                                ':smallImage' => $param['smallImage'],
                                ':mediumImage' => $param['mediumImage'],
                                ':largeImage' => $param['largeImage'],
            					':xlargeImage' => $param['xlargeImage'],
                                ':shortDetail' => $param['shortDetail'],
                                ':mediumDetail' => $param['mediumDetail'],
                                ':longDetail' => $param['longDetail'],
                                ':parent' => $param['parent'],
                                ':SEO_metaDescription' => $param['SEO_metaDescription'],
                                ':SEO_keyword' => $param['SEO_keyword'],
                                ':status' => $param['status'],
                                ':order' => $param['order'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
                                ':isGame' => $param['isGame'],
                                ':expire_date' => $param['expire_date'],
            					':type' => $param['type'],
            					':link_canonical' => $param['link_canonical']
                            );

            $this -> getContext() -> getTransaction() -> startTransaction('mobile');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	/*public function updateGameCGMB($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
                                    name = :name,
                                    mediumName = :mediumName,
                                    unique_name = :unique_name,
                                    SEO_Name = :SEO_Name,
                                    smallImage = :smallImage,
                                    mediumImage = :mediumImage,
                                    largeImage = :largeImage,
                                    xlargeImage = :xlargeImage,
                                    shortDetail = :shortDetail,
                                    mediumDetail = :mediumDetail,
                                    longDetail = :longDetail,
                                    parent = :parent,
                                    SEO_title = :SEO_title,
                                    SEO_metaDescription = :SEO_metaDescription,
                                    SEO_keyword = :SEO_keyword,
                                    status = :status,
                                    `order` = :order,
                                    hot_star = :hot_star,
                                    isEvent = :isEvent,
                                    isGame = :isGame,
                                    expire_date = :expire_date,
                                    tag = :tag,
                                    type = :type
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
                                ':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':SEO_Name' => $param['SEO_Name'],
                                ':smallImage' => $param['smallImage'],
                                ':mediumImage' => $param['mediumImage'],
                                ':largeImage' => $param['largeImage'],
            					':xlargeImage' => $param['xlargeImage'],
                                ':shortDetail' => $param['shortDetail'],
                                ':mediumDetail' => $param['mediumDetail'],
                                ':longDetail' => $param['longDetail'],
                                ':parent' => $param['parent'],
                                ':SEO_title' => $param['SEO_title'],
                                ':SEO_metaDescription' => $param['SEO_metaDescription'],
                                ':SEO_keyword' => $param['SEO_keyword'],
                                ':status' => $param['status'],
                                ':order' => $param['order'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
                                ':isGame' => $param['isGame'],
                                ':expire_date' => $param['expire_date'],
                                ':tag' => $param['tag'],
            					':type' => $param['type']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }*/
    
	public function updateGameMMBG($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
                                    name = :name,
                                    mediumName = :mediumName,
                                    unique_name = :unique_name,
                                    SEO_Name = :SEO_Name,
                                    smallImage = :smallImage,
                                    mediumImage = :mediumImage,
                                    largeImage = :largeImage,
                                    xlargeImage = :xlargeImage,
                                    shortDetail = :shortDetail,
                                    mediumDetail = :mediumDetail,
                                    longDetail = :longDetail,
                                    parent = :parent,
                                    SEO_metaDescription = :SEO_metaDescription,
                                    SEO_keyword = :SEO_keyword,
                                    status = :status,
                                    `order` = :order,
                                    hot_star = :hot_star,
                                    isEvent = :isEvent,
                                    isGame = :isGame,
                                    expire_date = :expire_date,
                                    type = :type,
                                    link_canonical = :link_canonical
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
                                ':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':SEO_Name' => $param['SEO_Name'],
                                ':smallImage' => $param['smallImage'],
                                ':mediumImage' => $param['mediumImage'],
                                ':largeImage' => $param['largeImage'],
            					':xlargeImage' => $param['xlargeImage'],
                                ':shortDetail' => $param['shortDetail'],
                                ':mediumDetail' => $param['mediumDetail'],
                                ':longDetail' => $param['longDetail'],
                                ':parent' => $param['parent'],
                                ':SEO_metaDescription' => $param['SEO_metaDescription'],
                                ':SEO_keyword' => $param['SEO_keyword'],
                                ':status' => $param['status'],
                                ':order' => $param['order'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
                                ':isGame' => $param['isGame'],
                                ':expire_date' => $param['expire_date'],
            					':type' => $param['type'],
            					':link_canonical' => $param['link_canonical']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	/*public function updateGameNSGT($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
                                    name = :name,
                                    mediumName = :mediumName,
                                    unique_name = :unique_name,
                                    SEO_Name = :SEO_Name,
                                    smallImage = :smallImage,
                                    mediumImage = :mediumImage,
                                    largeImage = :largeImage,
                                    xlargeImage = :xlargeImage,
                                    shortDetail = :shortDetail,
                                    mediumDetail = :mediumDetail,
                                    longDetail = :longDetail,
                                    parent = :parent,
                                    SEO_title = :SEO_title,
                                    SEO_metaDescription = :SEO_metaDescription,
                                    SEO_keyword = :SEO_keyword,
                                    status = :status,
                                    `order` = :order,
                                    hot_star = :hot_star,
                                    isEvent = :isEvent,
                                    isGame = :isGame,
                                    expire_date = :expire_date,
                                    tag = :tag,
                                    type = :type
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
                                ':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':SEO_Name' => $param['SEO_Name'],
                                ':smallImage' => $param['smallImage'],
                                ':mediumImage' => $param['mediumImage'],
                                ':largeImage' => $param['largeImage'],
            					':xlargeImage' => $param['xlargeImage'],
                                ':shortDetail' => $param['shortDetail'],
                                ':mediumDetail' => $param['mediumDetail'],
                                ':longDetail' => $param['longDetail'],
                                ':parent' => $param['parent'],
                                ':SEO_title' => $param['SEO_title'],
                                ':SEO_metaDescription' => $param['SEO_metaDescription'],
                                ':SEO_keyword' => $param['SEO_keyword'],
                                ':status' => $param['status'],
                                ':order' => $param['order'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
                                ':isGame' => $param['isGame'],
                                ':expire_date' => $param['expire_date'],
                                ':tag' => $param['tag'],
            					':type' => $param['type']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
         

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }*/
    
	public function updateGameAjaxTPG($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
            						name = :name,
                                    mediumName = :mediumName,
                                    unique_name = :unique_name,
                                    `order` = :order,
                                    hot_star = :hot_star,
                                    isEvent = :isEvent,
                                    type = :type,
                                    link_canonical = :link_canonical
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
            					':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':order' => $param['order'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
            					':type' => $param['type'],
           						':link_canonical' => $param['link_canonical']
                            );

            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateGameAjaxMobile($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
            						name = :name,
                                    mediumName = :mediumName,
                                    unique_name = :unique_name,
                                    `order` = :order,
                                    hot_star = :hot_star,
                                    isEvent = :isEvent,
                                    type = :type,
                                    link_canonical = :link_canonical
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
            					':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':order' => $param['order'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
            					':type' => $param['type'],
            					':link_canonical' => $param['link_canonical'],
                            );

            $this -> getContext() -> getTransaction() -> startTransaction('mobile');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	/*public function updateGameAjaxCGMB($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
            						name = :name,
                                    mediumName = :mediumName,
                                    unique_name = :unique_name,
                                    `order` = :order,
                                    hot_star = :hot_star,
                                    isEvent = :isEvent,
                                    type = :type
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
            					':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':order' => $param['order'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
            					':type' => $param['type']
                            );

            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }*/
    
	public function updateGameAjaxMMBG($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
            						name = :name,
                                    mediumName = :mediumName,
                                    unique_name = :unique_name,
                                    `order` = :order,
                                    hot_star = :hot_star,
                                    isEvent = :isEvent,
                                    type = :type,
                                    link_canonical = :link_canonical
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
            					':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':order' => $param['order'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
            					':type' => $param['type'],
            					':link_canonical' => $param['link_canonical']
                            );

            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	/*public function updateGameAjaxNSGT($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game SET
            						name = :name,
                                    mediumName = :mediumName,
                                    unique_name = :unique_name,
                                    `order` = :order,
                                    hot_star = :hot_star,
                                    isEvent = :isEvent,
                                    type = :type
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
            					':name' => $param['name'],
                                ':mediumName' => $param['mediumName'],
            					':unique_name' => $param['unique_name'],
                                ':order' => $param['order'],
                                ':hot_star' => $param['hot_star'],
                                ':isEvent' => $param['isEvent'],
            					':type' => $param['type']
                            );

            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }*/
    
    public function deleteGameTPG($id) {
        try {

            $inSQL = "   DELETE FROM game WHERE id = :id ";
            $param = array(':id' => $id);

            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
	public function deleteGameTempTPG() {
        try {

            $inSQL = "DELETE FROM `game_temp` WHERE 1";
			
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
        	print_r($exception);
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
	public function deleteGameMMBGTempTPG() {
        try {

            $inSQL = "DELETE FROM `game_temp` WHERE 2";
			
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
        	print_r($exception);
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
	public function deleteGameMobile($id) {
        try {

            $inSQL = "   DELETE FROM game WHERE id = :id ";
            $param = array(':id' => $id);

            $this -> getContext() -> getTransaction() -> startTransaction('mobile');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
	public function deleteGameCGMB($id) {
        try {

            $inSQL = "   DELETE FROM game WHERE id = :id ";
            $param = array(':id' => $id);
            
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
	public function deleteGameMMBG($id) {
        try {

            $inSQL = "   DELETE FROM game WHERE id = :id ";
            $param = array(':id' => $id);
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
	public function deleteGameNSGT($id) {
        try {

            $inSQL = "   DELETE FROM game WHERE id = :id ";
            $param = array(':id' => $id);
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);
            $this -> getContext() -> getTransaction() -> closeTransaction();

        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
	public function getSubsribeAll() {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "SELECT * FROM subsribe";
            
           	$result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }

}
?>